<template>
  <div class="app-container">
    {{ activeState }}
    <Workflow
      :active-state="activeState"
      :workflow-configs="workflowConfigs"
      @change="handleWorkflow"
    />

    <div>
      <el-button type="primary" @click="reset_all()">
        复位
      </el-button>
    </div>
  </div>
</template>

<script>
import odoo from '@/odooapi'

import Workflow from '@/selfComponents/Workflow'

const modelName = 'Test/HrExpenseSheetDetail'

export default {
  name: 'TestWorkflow',
  components: { Workflow },
  directives: {},
  filters: {},

  data() {
    return {
      modelName: modelName,
      activeState: { value: 'draft' },
      workflowConfigs: {
        states: {},
        actions: {},
        transfers: {}
      }
    }
  },

  computed: {},

  async created() {
    this.Model = odoo.env(this.modelName)

    const { workflow } = this.Model.configs
    this.workflowConfigs = workflow
  },

  methods: {
    handleWorkflow(active_state) {
      console.log('xxxx,', active_state)
      // to call  odooo
      if (active_state.value !== 'update') {
        this.activeState = active_state
      } else {
        console.log('to update')
      }
    },

    reset_all() {
      this.activeState = { value: 'draft' }
    }
  }
}
</script>
